using System;

namespace RxjhServer
{
	public class MoveVector
	{
		private float destX;

		private float destY;

		private float destZ;

		private float fromX;

		private float fromY;

		private float fromZ;

		private float reach;

		private float speed;

		private DateTime timestamp;

		public MoveVector(Players Play, float x, float y, float z)
		{
			timestamp = DateTime.Now;
			destX = x;
			destY = y;
			destZ = z;
			fromX = Play.人物坐标_X;
			fromY = Play.人物坐标_Y;
			fromZ = Play.人物坐标_Z;
			speed = Play.Speed;
			float num = x - Play.人物坐标_X;
			float num2 = y - Play.人物坐标_Y;
			float num3 = (float)Math.Sqrt(num * num + num2 * num2);
			reach = num3 / (Play.Speed / 1000f);
		}

		public MoveVector(Players Play, float x, float y, float z, float fromx, float fromy, float fromz)
		{
			timestamp = DateTime.Now;
			destX = x;
			destY = y;
			destZ = z;
			fromX = fromx;
			fromY = fromy;
			fromZ = fromz;
			speed = Play.Speed;
			float num = x - Play.人物坐标_X;
			float num2 = y - Play.人物坐标_Y;
			float num3 = (float)Math.Sqrt(num * num + num2 * num2);
			reach = num3 / (Play.Speed / 1000f);
		}

		public void Get(out float x, out float y, out float z)
		{
			float num = (float)DateTime.Now.Subtract(timestamp).TotalMilliseconds / reach;
			if (reach == 15f || num > 31f)
			{
				x = destX;
				y = destY;
				z = destZ;
				return;
			}
			float num2 = destX - fromX;
			float num3 = destY - fromY;
			float num4 = destZ - fromZ;
			num2 *= num;
			num3 *= num;
			num4 *= num;
			x = fromX + num2;
			y = fromY + num3;
			z = fromZ + num4;
		}

		public bool NearDestination()
		{
			float num = (float)DateTime.Now.Subtract(timestamp).TotalMilliseconds - reach;
			return num < 1000f;
		}

		public bool ReachDestination()
		{
			float num = (float)DateTime.Now.Subtract(timestamp).TotalMilliseconds / reach;
			return num > 1f || reach == 0f;
		}

		public void Update(float x, float y, float z, float speed)
		{
			Get(out fromX, out fromY, out fromZ);
			timestamp = DateTime.Now;
			float num = x - fromX;
			float num2 = y - fromY;
			destX = x;
			destY = y;
			destZ = z;
			float num3 = (float)Math.Sqrt(num * num + num2 * num2);
			reach = num3 / (speed / 1000f);
		}
	}
}
